var express = require('express');
var router = express.Router();
var mongo = require("./db")

/* GET users listing. */
router.get('/', function (req, res, next) {
  res.send('respond with a resource');
});
router.post("/addstuedent", function (req, res) {
  var obj = {
    username: req.body.username,
    age: req.body.age,
    sex: req.body.sex,
    hobby: req.body.hobby
  }
  mongo("insert", "studentlist", obj, function () {
    // 重定向
    // res.redirect("http://127.0.0.1:3000/msg.html")
    res.send({ success: "提交成功" })
  })
})
module.exports = router;
